<template>
  <div class="blog-head--logged">
    <ElAvatar :size="50" class="blog-head--avatar" :src="url" />
    <IEpSwitchButton class="blog-logout-icon" @click="logout" />
  </div>
</template>

<script setup lang="ts">
import { computed } from 'vue'

import { useUser } from '@/store/user'
let user = useUser()
let url = computed<string>(() => user?.userInfo?.avatar)
function logout() {
  user?.logout(`再见, ${user?.userInfo?.nickName}`)
}
</script>
<style lang="less" scoped>
.blog-head--logged {
  display: flex;
  align-items: center;
}

.blog-head--avatar.el-avatar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  margin-right: 20px;
  overflow: hidden;
  border-radius: 50%;
}

.blog-logout-icon {
  cursor: pointer;
  transition: 0.2s;
  transform: scale(1);

  &:hover {
    transform: scale(1.2);
  }
}
</style>
